package com.daocao.hua.api.requestInfo;

import com.daocao.hua.api.Api;
import com.daocao.hua.api.bean.MoneyRewardBean;
import com.daocao.hua.api.bean.PageBean;
import com.daocao.hua.api.bean.ShareMoneyBean;
import com.daocao.hua.api.callback.InviteRecordContract;
import com.daocao.hua.util.Network;
import com.daocao.hua.util.RxLifeUtil;
import com.daocao.hua.util.ToastUtil;

/**
 * Created by Administrator on 2017/5/14.
 */

public class InviteRecordRequest extends BaseRequest<InviteRecordContract.View> implements InviteRecordContract.Presenter<InviteRecordContract.View> {

    public static InviteRecordRequest create() {
        return new InviteRecordRequest();
    }


    @Override
    public void getShareRecord(int page, int pagesize) {
        if (!Network.checkNetwork(BaseContext)) {
            ToastUtil.makeText(BaseContext, networkFail).show();
            return;
        }
        mView.onRequestStart();
        PageBean bean = new PageBean();
        bean.page = page;
        Api.api_service.getMoneyV3Reward(bean).compose(RxLifeUtil.checkOn(BaseContext)).
                doFinally(() -> {
                    try {
                        mView.complete();
                    } catch (NullPointerException e) {

                    }
                }).
                subscribe(result -> {
                    mView.getShareRecordSuccess(page, result);
                });
    }

}
